<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
      <ui:composition template="ClientTemplate.xhtml">   
        <ui:define name="body">  
            <h:form id="form">
                <p:growl id="noticeMessage" />  
                <p:dataTable id="dataTable" var="item" value="#{userController.listUserByID(loginController.userLogin.usID)}"
                             paginator="true" rows="10" paginatorPosition="bottom"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15" style="width: 100%" widgetVar="userTable"
                             editable="true" resizableColumns="true">
                    <f:facet name="header">
                        <h:outputText value="My Information"/>                  
                    </f:facet>

                    <p:ajax event="rowEdit" listener="#{userController.onEdit}" />
                    <p:ajax event="rowEditCancel" listener="#{userController.onEditCancel}" />

                    <p:column headerText="ID"  disabledSelection="false">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usID}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usID}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Name">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usName}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.usName}" style="width: 100%">
                                    <f:validateLength minimum="6" /> 
                                </h:inputText>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>                
                    <p:column headerText="UserName" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usUserName}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.usUserName}" style="width: 100%">
                                    <f:validateLength minimum="6" maximum="10" />
                                </h:inputText>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>

                    <p:column headerText="Email" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usEmail}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.usEmail}" style="width: 100%">
                                    <!-- <f:validateRegex pattern="^[a-zA-Z]" /> -->
                                </h:inputText>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Phone" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usPhone}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.usPhone}" style="width: 100%">
                                    <!-- <f:validateRegex pattern="^[a-zA-Z]" /> -->
                                </h:inputText>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Adress" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usAdress}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.usAdress}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>               
                    <p:column headerText="Company" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usCompany}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.usCompany}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>          
                    <p:column headerText="Status" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usStatus}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usStatus}"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column> 
                    <p:column headerText="Action">
                        <h:commandButton action="#{userController.resetPassword(item)}" value="Reset Password"/>
                    </p:column>
                    <p:column>
                        <p:rowEditor/>
                    </p:column>
                </p:dataTable>
              
            </h:form>
        </ui:define>
    </ui:composition>
</html>

